﻿package mortal.game.view.skill.panel.render
{
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import com.mui.controls.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.skill.panel.data.*;

    public class SkillRuneSmallItem extends GSprite
    {
        private var _bg:GBitmap;
        private var _iconContainer:ToolTipSprite;
        private var _icon:GBitmap;
        private var _txtLv:GTextFiled;
        private var _lastImageUrl:String;

        public function SkillRuneSmallItem()
        {
            return;
        }// end function

        public function set runeData(param1:RuneItemData) : void
        {
            if (param1 != null)
            {
                this._iconContainer.toolTipData = param1.info;
            }
            else
            {
                this._iconContainer.toolTipData = null;
            }
            if (param1.actived)
            {
                this._txtLv.text = param1.info.level.toString();
                this._txtLv.x = 11;
                this._txtLv.y = 6;
                this._iconContainer.filters = [];
            }
            else
            {
                this._txtLv.text = Language.getString(21081);
                this._txtLv.x = 9;
                this._txtLv.y = 5;
                this._iconContainer.filters = [FilterConst.colorFilter];
            }
            if (this._lastImageUrl)
            {
                LoaderManager.instance.removeResourceEvent(this._lastImageUrl, this.onLoadCompleteHandler);
                this._lastImageUrl = null;
            }
            this._lastImageUrl = param1.info.icon + ".png";
            LoaderManager.instance.load(this._lastImageUrl, this.onLoadCompleteHandler, LoaderPriority.LevelB);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseChildren = true;
            this.mouseEnabled = true;
            this._bg = UIFactory.gBitmap(ImagesConst.SkillRuneSmallBg, 0, 0, this);
            this._iconContainer = UICompomentPool.getUICompoment(ToolTipSprite) as ToolTipSprite;
            this._iconContainer.mouseChildren = true;
            this._iconContainer.mouseEnabled = true;
            this.addChild(this._iconContainer);
            this._iconContainer.x = 3;
            this._iconContainer.y = 3;
            this._icon = UIFactory.gBitmap(null, 0, 0, this._iconContainer);
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.size = 9;
            _loc_1.color = 15658734;
            this._txtLv = UIFactory.gTextField("", 12, 6, 40, 20, this, _loc_1);
            this._txtLv.mouseEnabled = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (this._lastImageUrl != null)
            {
                LoaderManager.instance.removeResourceEvent(this._lastImageUrl, this.onLoadCompleteHandler);
                this._lastImageUrl = null;
            }
            this._bg.dispose(param1);
            this._bg = null;
            this._icon.dispose(param1);
            this._icon = null;
            this._txtLv.dispose(param1);
            this._txtLv = null;
            return;
        }// end function

        protected function onLoadCompleteHandler(param1:ImageInfo) : void
        {
            this._lastImageUrl = null;
            if (isDisposed)
            {
                return;
            }
            this._icon.bitmapData = param1.bitmapData;
            this._icon.width = 18;
            this._icon.height = 18;
            setSize(_width, _height);
            return;
        }// end function

    }
}
